#import "RNList.h"
#import "RNConstants.h"
#import "RNListItem.h"

@implementation RNList 

@dynamic title;
@dynamic items;
@dynamic icon;

-(BOOL)canContainObjectsWithEntityNames:(NSArray *)entityNames {
    NSArray *validEntities = [entityNames filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self IN { %@, %@, %@ }", RNEntityNameListItem, RNEntityNameItem, RNEntityNameHistoryItem]];
    return ([validEntities count] == [entityNames count]);
}

-(NSArray *)children {
    return nil;
}

-(id)parent {
    return nil;
}

+(NSSet *)keyPathsForValuesAffectingObjectDictionary {
    return [NSSet setWithObjects:@"title", @"items", nil];
}

-(NSDictionary *)objectDictionary {
    NSMutableDictionary *objectDictionary = [NSMutableDictionary dictionary];
    [objectDictionary setValue:[self title] forKey:RNTitleKey];
    NSSet *incompleteItems = [[self items] filteredSetUsingPredicate:[NSPredicate predicateWithFormat:@"complete == NO"]];
    [objectDictionary setValue:[NSNumber numberWithInteger:[incompleteItems count]] forKey:@"itemCount"];
    [objectDictionary setValue:[self icon] forKey:@"icon"];
    return objectDictionary;
}

@end
